{
 "cells": [
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-24T13:31:09.366867Z",
     "start_time": "2025-10-24T13:31:09.364542Z"
    }
   },
   "cell_type": "code",
   "source": [
    "def func_01(num):\n",
    "    num+=1\n",
    "    return num"
   ],
   "id": "b316e15f2dd0f994",
   "outputs": [],
   "execution_count": 1
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-24T13:31:09.389610Z",
     "start_time": "2025-10-24T13:31:09.387372Z"
    }
   },
   "cell_type": "code",
   "source": [
    "a=10\n",
    "print(func_01(a))\n",
    "print(a)\n",
    "#string、tuples、numbers类似与值传递"
   ],
   "id": "9570b7194827f6c9",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "11\n",
      "10\n"
     ]
    }
   ],
   "execution_count": 2
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-24T13:31:09.402419Z",
     "start_time": "2025-10-24T13:31:09.400254Z"
    }
   },
   "cell_type": "code",
   "source": [
    "def func_02(l):\n",
    "    l.pop()\n",
    "    return l"
   ],
   "id": "7db5654cec53ce78",
   "outputs": [],
   "execution_count": 3
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-24T13:31:09.424371Z",
     "start_time": "2025-10-24T13:31:09.421486Z"
    }
   },
   "cell_type": "code",
   "source": [
    "b=[2,3,4]\n",
    "print(func_02(b))\n",
    "print(b)\n",
    "#list,dict类似于地址传递"
   ],
   "id": "e2f606f3a5e21935",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[2, 3]\n",
      "[2, 3]\n"
     ]
    }
   ],
   "execution_count": 4
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-24T13:31:09.436787Z",
     "start_time": "2025-10-24T13:31:09.434384Z"
    }
   },
   "cell_type": "code",
   "source": [
    "#传入参数的几种方法\n",
    "print(func_01(2))\n",
    "print(func_01(num = 2))\n",
    "#第二种传参的方法可以忽略顺序"
   ],
   "id": "13bd6e1d530c0f95",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3\n",
      "3\n"
     ]
    }
   ],
   "execution_count": 5
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-24T13:31:09.449329Z",
     "start_time": "2025-10-24T13:31:09.447337Z"
    }
   },
   "cell_type": "code",
   "source": [
    "def func_03(l):\n",
    "    l.append(3)\n",
    "    #这种类似于地址传递的可以不用return，因为是从地址上来操作的"
   ],
   "id": "6c968e06ac80b73c",
   "outputs": [],
   "execution_count": 6
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-24T13:31:09.489295Z",
     "start_time": "2025-10-24T13:31:09.486914Z"
    }
   },
   "cell_type": "code",
   "source": [
    "c=['a','b','c']\n",
    "func_03(c)\n",
    "print(c)"
   ],
   "id": "4e7e1dd93f983a8c",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['a', 'b', 'c', 3]\n"
     ]
    }
   ],
   "execution_count": 7
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
